package com.dynamixsoftware.printershare.bt;

import com.dynamixsoftware.printershare.App;
import java.util.UUID;

public class BTDevice {
	private static final UUID UUID_RFCOMM = UUID
			.fromString("00001101-0000-1000-8000-00805F9B34FB");
	private String address;
	private BTAdapter bta;
	private Integer dclass;
	private String name;

	BTDevice(BTAdapter paramBTAdapter, String paramString1,
			String paramString2, Integer paramInteger) {
		this.bta = paramBTAdapter;
		this.address = paramString1;
		this.name = paramString2;
		this.dclass = paramInteger;
	}

	public BTSocket connectRfcommSocket()
    throws Exception
  {
    /*BTSocket localBTSocket1 = null;
    BTSocket localBTSocket2 = null;
    BTSocket localBTSocket3 = null;
    BTSocket localBTSocket4 = null;
    int i;
    this.bta.cancelDiscovery();
    try
    {
      localBTSocket1 = this.bta.createInsecureRfcommSocketToServiceRecord(this.address, UUID_RFCOMM);
      if (localBTSocket1 != null)
      {
        boolean bool4 = localBTSocket1.connect();
        if (bool4) {
          return localBTSocket1;
        }
      }
    }
    catch (Exception localException1)
    {
      localException1.printStackTrace();
      App.reportThrowable(localException1);
      if (localBTSocket1 != null) {}
      try
      {
        localBTSocket1.destroy();
        localBTSocket2 = null;
        this.bta.cancelDiscovery();
      }
      catch (Exception localException7)
      {
        for (;;)
        {
          try
          {
            localBTSocket2 = this.bta.createRfcommSocketToServiceRecord(this.address, UUID_RFCOMM);
            if (localBTSocket2 == null) {
              continue;
            }
            boolean bool3 = localBTSocket2.connect();
            if (!bool3) {
              continue;
            }
            return localBTSocket2;
          }
          catch (Exception localException2)
          {
            localBTSocket2 = null;
            localException2.printStackTrace();
            App.reportThrowable(localException2);
            if (localBTSocket2 == null) {
              continue;
            }
            try
            {
              localBTSocket2.destroy();
              localBTSocket3 = null;
              i = 1;
              if ((this.name == null) || ((!this.name.startsWith("OJL411")) && (!this.name.startsWith("OJL511")))) {
                continue;
              }
              i = 3;
              this.bta.cancelDiscovery();
            }
            catch (Exception localException6)
            {
              try
              {
                localBTSocket3 = this.bta.createInsecureRfcommSocket(this.address, i);
                if (localBTSocket3 == null) {
                  break label243;
                }
                Boolean bool2 = localBTSocket3.connect();
                if (!bool2) {
                  break label243;
                }
                return localBTSocket3;
              }
              catch (Exception localException3)
              {
                localException3.printStackTrace();
                App.reportThrowable(localException3);
                if (localBTSocket3 == null) {
                  break label253;
                }
                try
                {
                  localBTSocket3.destroy();
                  localBTSocket4 = null;
                  this.bta.cancelDiscovery();
                }
                catch (Exception e)
                {
                  for (;;)
                  {
                    try
                    {
                      localBTSocket4 = this.bta.createRfcommSocket(this.address, i);
                      if (localBTSocket4 == null) {
                        continue;
                      }
                      Boolean bool1 = localBTSocket4.connect();
                      if (!bool1) {
                        continue;
                      }
                      return localBTSocket4;
                    }
                    catch (Exception localException4)
                    {
                      localException4.printStackTrace();
                      App.reportThrowable(localException4);
                      if (localBTSocket4 == null) {
                        break label335;
                      }
                    }
                    e = e;
                    e.printStackTrace();
                    App.reportThrowable(e);
                  }
                }
              }
              localException7 = localException7;
              localException7.printStackTrace();
              App.reportThrowable(localException7);
              continue;
            }
          }
          Exception localException8 = null ;
          localException8.printStackTrace();
          App.reportThrowable(localException8);
        }
      }
    }
    try
    {
//      BTSocket localBTSocket3;
//      int i;
//      boolean bool2;
//      label243:
//      label253:
//      BTSocket localBTSocket4;
//      boolean bool1;
//      localBTSocket4.destroy();
//      label335:
      return null;
    }
    catch (Exception localException5)
    {
//      for (;;)
//      {
//        localException5.printStackTrace();
//        App.reportThrowable(localException5);
//      }
    }
	return localBTSocket4;*/
		return null;
  }

	public boolean createBond() throws Exception {
		this.bta.cancelDiscovery();
		return this.bta.createBond(this.address);
	}

	public String getAddress() {
		return this.address;
	}

	public boolean getBondState() throws Exception {
		return this.bta.getBondState(this.address);
	}

	public Integer getDeviceClass() {
		return this.dclass;
	}

	public String getName() {
		if ((this.name != null) && (!this.address.equals(this.name))
				&& (!this.address.equals(this.name.replace('-', ':')))) {
			return this.name;
		}
		return null;
	}
}

/*
 * Location:
 * C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar
 * .jar
 * 
 * Qualified Name: com.dynamixsoftware.printershare.bt.BTDevice
 * 
 * JD-Core Version: 0.7.0.1
 */